import { getPostList } from "@/api/post";
import { ProTable } from "@ant-design/pro-components";
import { Component } from "react";

export default class PostsList extends Component {
  columns = [
    { title: "标题", dataIndex: "title" },
    {
      title: "正文",
      dataIndex: "body",
      render: (_: any, record: any) => (
        <div dangerouslySetInnerHTML={{ __html: record.body }}></div>
      ),
    },
  ];

  render() {
    return (
      <div>
        <h1>帖子列表</h1>

        <ProTable
          rowKey="id"
          columns={this.columns}
          request={async () => {
            // 调用接口
            const resp = await getPostList();
            return {
              data: resp,
            };
          }}
        />
      </div>
    );
  }
}
